package com.ruoyi.service.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.service.domain.CheServiceItemsMid;
import com.ruoyi.service.service.ICheServiceItemsMidService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 服务详情与服务中间表Controller
 * 
 * @author ruoyi
 * @date 2025-01-03
 */
@RestController
@RequestMapping("/mid")
public class CheServiceItemsMidController extends BaseController
{
    @Autowired
    private ICheServiceItemsMidService cheServiceItemsMidService;

    /**
     * 查询服务详情与服务中间表列表
     */
    @RequiresPermissions("service:mid:list")
    @GetMapping("/list")
    public TableDataInfo list(CheServiceItemsMid cheServiceItemsMid)
    {
        startPage();
        List<CheServiceItemsMid> list = cheServiceItemsMidService.selectCheServiceItemsMidList(cheServiceItemsMid);
        return getDataTable(list);
    }

    /**
     * 导出服务详情与服务中间表列表
     */
    @RequiresPermissions("service:mid:export")
    @Log(title = "服务详情与服务中间表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CheServiceItemsMid cheServiceItemsMid)
    {
        List<CheServiceItemsMid> list = cheServiceItemsMidService.selectCheServiceItemsMidList(cheServiceItemsMid);
        ExcelUtil<CheServiceItemsMid> util = new ExcelUtil<CheServiceItemsMid>(CheServiceItemsMid.class);
        util.exportExcel(response, list, "服务详情与服务中间表数据");
    }

    /**
     * 获取服务详情与服务中间表详细信息
     */
    @RequiresPermissions("service:mid:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(cheServiceItemsMidService.selectCheServiceItemsMidById(id));
    }

    /**
     * 新增服务详情与服务中间表
     */
    @RequiresPermissions("service:mid:add")
    @Log(title = "服务详情与服务中间表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CheServiceItemsMid cheServiceItemsMid)
    {
        return toAjax(cheServiceItemsMidService.insertCheServiceItemsMid(cheServiceItemsMid));
    }

    /**
     * 修改服务详情与服务中间表
     */
    @RequiresPermissions("service:mid:edit")
    @Log(title = "服务详情与服务中间表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CheServiceItemsMid cheServiceItemsMid)
    {
        return toAjax(cheServiceItemsMidService.updateCheServiceItemsMid(cheServiceItemsMid));
    }

    /**
     * 删除服务详情与服务中间表
     */
    @RequiresPermissions("service:mid:remove")
    @Log(title = "服务详情与服务中间表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(cheServiceItemsMidService.deleteCheServiceItemsMidByIds(ids));
    }
}
